package com.intellif.spring_boot_autoconfiguration.bootstrap;

import com.intellif.spring_boot_autoconfiguration.annotation.EnableHelloWorld;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;

/**
 * 注解形式和编程方式
 */
@EnableHelloWorld
public class EnableHelloWorldBootstrap {
    public static void main(String[] args) {
        ConfigurableApplicationContext applicationContext = new SpringApplicationBuilder(EnableHelloWorldBootstrap.class)
                .web(WebApplicationType.NONE)
                .run(args);
        String helloWorld = applicationContext.getBean("helloWorld", String.class);
        System.out.println("hello world bean"+helloWorld);
        applicationContext.close();

    }
}
